<?php

namespace App\Models\Order;

use App\Models\BasicModel;

class OrderModel extends BasicModel
{
    protected $table = 'orders';

    protected $primaryKey = 'order_id';

    protected $fillable = [
        'order_id',
        'order_no',
        'user_id',
        'total_amount',
        'pay_status',
        'pay_type',
        'pay_time',
        'wx_pay_order_no',
        'wx_mch_id',
        'wx_appid',
        'wx_pay_key',
        'alipay_trade_no',
        'alipay_buyer_id',
        'alipay_seller_id',
        'shipping_name',
        'shipping_phone',
        'shipping_address',
        'order_status',
        'created_at',
        'updated_at',
        'status'
    ];

    protected $casts = [
        'order_id' => 'integer',
        'order_no' => 'string',
        'user_id' => 'integer',
        'total_amount' => 'decimal:2',
        'pay_status' => 'integer',
        'pay_type' => 'integer',
        'pay_time' => 'datetime',
        'wx_pay_order_no' => 'string',
        'wx_mch_id' => 'string',
        'wx_appid' => 'string',
        'wx_pay_key' => 'string',
        'alipay_trade_no' => 'string',
        'alipay_buyer_id' => 'string',
        'alipay_seller_id' => 'string',
        'shipping_name' => 'string',
        'shipping_phone' => 'string',
        'shipping_address' => 'string',
        'order_status' => 'integer',
        'created_at' => 'string',
        'updated_at' => 'string'
    ];

    protected $hidden = [
        'created_at',
        'updated_at'
    ];

    public function subs(){
        return $this->hasMany(OrderSubModel::class,'order_id','order_id');
    }



}
